$(document).ready(function(){
    init();

    //设置滚动条
    $("#app").slimScroll({
        height: $(window).height(), //可滚动区域高度
        size: '3px', //滚动条宽度，即组件宽度
    });
});

function init(){
    var currentTheme =  localStorage.getItem('theme');
    if(currentTheme) {
        $('#theme').attr("href",'../material/css/colors/'+currentTheme+'.css');
    }
    if(window.localStorage.setting != null){
        //隐藏查询
        var setting = JSON.parse(window.localStorage.setting);
        if($.inArray("search", setting)>= 0){
            $("#searchDiv").hide();
            if($table!=null){
                $table.resize(autoHeigth());
            }
        }else{
            $("#searchDiv").show();
            if($table!=null){
                $table.resize(autoHeigth());
            }
        }
    }
}

function changeIframe() {
    init();
}

$(document).ready(function () {
    $('.collapse-link').on('click', function () {
        var ibox = $(this).closest('div.ibox');
        var button = $(this).find('i');
        var content = ibox.children('.ibox-content');
        content.slideToggle(200);
        button.toggleClass('fa-chevron-up').toggleClass('fa-chevron-down');
        ibox.toggleClass('').toggleClass('border-bottom');
        setTimeout(function () {
            ibox.resize();
            ibox.find('[id^=map-]').resize();
        }, 50);
    });
});

function setICheck(name) {
    var currentTheme =  localStorage.getItem('theme');
    if(window.localStorage.checkType != null ){
        var skin = "blue";
        if(currentTheme == 'purple-dark'){
            skin = "purple";
        }else if(currentTheme == 'blue-dark'){
            skin = "blue";
        }else if(currentTheme == 'green-dark'){
            skin = "aero";
        }else if(currentTheme == 'red-dark'){
            skin = "red";
        }else if(currentTheme == 'megna-dark'){
            skin = "green";
        }else if(currentTheme == 'default-dark'){
            skin = "grey";
        }
        if(window.localStorage.checkType == 'square'){
            $('input[name='+name+']').iCheck({
                checkboxClass: 'icheckbox_square-'+skin,
                radioClass: 'iradio_square-'+skin,
                increaseArea: '20%' // optional
            });
            $('#skin').attr("href","../assets/plugins/icheck/skins/square/"+skin+".css");
        }else if(window.localStorage.checkType == 'polaris'){
            $('#skin').attr("href","../assets/plugins/icheck/skins/polaris/polaris.css");
            $('input[name='+name+']').iCheck({
                checkboxClass: 'icheckbox_polaris',
                radioClass: 'iradio_polaris',
                increaseArea: '-10%' // optional
            });
        }else if(window.localStorage.checkType == 'original'){
            $('input').iCheck('destroy');
        }
    }
}